package com.mall.controller;

import com.mall.annotation.OperationLog;
import com.mall.db.domain.Comments;
import com.mall.db.service.CommentsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/cc")
public class commentController extends BaseController<Comments>{

    @Resource(name="commentsService")
    private CommentsService cs;


    @Override
    public Map<String, Object> find(Comments com) {
        Date date=com.getCreateTime();
        if (date.equals(null)){
            com.setCreateTime(new Date());
        }
        List<Comments> list = cs.find();
        return this.findMap(list,list.size());
    }

    @Override
    @OperationLog(value = "删除评论",type = 0)
    public Map<String, Object> delete(Comments comments) {
        boolean b=cs.removeById(comments);
        return this.iud("删除",b,comments);
    }

}
